# 先下载安装所需的依赖包
#  pip install flask          设计后端接口的依赖包
#  pip install  flask-cors     设置前后端跨域内容的依赖包
#  pip install pymysql         flask连接操作数据库的依赖包
from flask import Flask,request,jsonify
from flask_cors import CORS
import flaskpy as mypy  # 确保这个模块是存在的
# 后端启动服务
app = Flask(__name__)
CORS(app,resources=r'/*')    ##设置跨域策略 


#第一个接口

@app.route('/qm')
def qm():
    sql = "select id,data,time from qm"   
    data = mypy.sql_model(sql)     
    return {"abc": data}

# @app.route('/gc')
# def gc():
#     sql = "select y,y1 from gc"   
#     data = mypy.sql_model(sql)      
#     y = [item['y']for item in data]
#     y1 = [item['y1']for item in data]
#     return {"y": y,"y1": y1}



if __name__ == "__main__":
    app.run(host='0.0.0.0',port=8000,debug=True)    ##启动接口服务，端口号是8000
    print("Good bye")